Skip to content

Fix WASM cfg proxy: remove test arm from wasm32 guards#116

Merged
cderv merged 3 commits intomainfrom
fix/wasm-cfg-proxy-and-cleanup
Apr 16, 2026
Merged

Fix WASM cfg proxy: remove test arm from wasm32 guards#116
cderv merged 3 commits intomainfrom
fix/wasm-cfg-proxy-and-cleanup

Conversation

@cderv
Copy link
Copy Markdown
Collaborator

@cderv cderv commented Apr 14, 2026

The #[cfg(any(target_arch = "wasm32", test))] pattern in filter.rs and
shortcode.rs forced native tests through the WASM-restricted Lua stdlib.
This caused Windows test failures because the restricted stdlib (no io/os/debug)
doesn't work with Lua's C implementation on native targets.

Fix

Remove the test arm from the cfg guards so native tests use Lua::new() with
the full stdlib. WASM coverage is provided by dedicated WASM tests in CI.

Also marks the dofile_wasm::test_dofile_script_dir_stack test as
#[cfg_attr(not(target_arch = "wasm32"), ignore)] since it depends on
register_wasm_dofile which is only available in the WASM build.

Changed files

  • crates/pampa/src/lua/filter.rs — cfg guard fix
  • crates/pampa/src/lua/shortcode.rs — cfg guard fix
  • crates/pampa/src/lua/dofile_wasm.rs — ignore test on native
  • .claude/rules/wasm.md — document the prohibited cfg pattern
  • claude-notes/instructions/testing.md — update testing docs
  • dev-docs/wasm.md — update WASM architecture docs

@vezwork
Copy link
Copy Markdown
Collaborator

vezwork commented Apr 15, 2026

@cscheid I'm gonna want something like wasm-qmd-parser again in the future for the Quarto extension, but putting that off for now.

@cderv
Copy link
Copy Markdown
Collaborator Author

cderv commented Apr 15, 2026

Let's leave it then - I was just trying to cleanup while understanding things around and fixing the problem I found.

@cderv cderv changed the title Fix WASM cfg proxy and remove stale wasm-qmd-parser crate Fix WASM cfg proxy and clean up stale references Apr 16, 2026
@cderv
Copy link
Copy Markdown
Collaborator Author

cderv commented Apr 16, 2026

Done — I've kept the crate skeleton (Cargo.toml, src/, tests/, licenses) and cleaned up the stale parts (old CI configs, C shim superseded by wasm-c-shim, wasm-sysroot headers, wasm-pack demo artifacts). The README now documents it as dormant.

Edit: I’ll probably split work on this. No need to cleanup if you plan to rework on it. But this is definitely stale.

@cderv cderv marked this pull request as draft April 16, 2026 11:31
cderv added 3 commits April 16, 2026 13:56
The cfg pattern #[cfg(any(target_arch = "wasm32", test))] forced native
tests through the WASM-restricted Lua stdlib (no io/os, synthetic modules
only). This caused 8 Windows test failures because the restricted stdlib
doesn't work without a real wasm32 target.

Change to #[cfg(target_arch = "wasm32")] so native tests use Lua::new()
with the full C stdlib on all platforms. WASM-specific code paths will be
tested by dedicated WASM smoke tests on the real wasm32 target in CI.
The test_dofile_script_dir_stack test validates WASM-specific dofile
behavior (script directory tracking via the VFS dofile override). The
native C dofile does not track the script directory stack, so this test
only passes on wasm32. Mark it ignored on native targets.

See #112 for the behavioral difference discussion.
- Add .claude/rules/wasm.md: prevent cfg test proxy regression
- Update xtask.md: wasm-pack → wasm-bindgen-cli, add version pinning
- Update testing.md: native tests use Lua::new(), remove stale cfg proxy docs
- Rewrite dev-docs/wasm.md: replace stale wasm-qmd-parser content with
  current wasm-quarto-hub-client architecture
@cderv cderv force-pushed the fix/wasm-cfg-proxy-and-cleanup branch from 6009f60 to 2db6f1e Compare April 16, 2026 12:58
@cderv cderv changed the title Fix WASM cfg proxy and clean up stale references Fix WASM cfg proxy: remove test arm from wasm32 guards Apr 16, 2026
@cderv
Copy link
Copy Markdown
Collaborator Author

cderv commented Apr 16, 2026

Split this PR — the wasm-qmd-parser cleanup and workflow modernization are now in #125. This PR is just the cfg guard fix (removing the test arm from #[cfg(any(target_arch = "wasm32", test))]).

@gordonwoodhull
Copy link
Copy Markdown
Collaborator

Thanks @cderv!

I've gone back and verified that adding test was a misunderstanding. The intent was to test io and os using the wasm runtime, not to make native tests use the wasm runtime!

@cderv cderv marked this pull request as ready for review April 16, 2026 15:36
@cderv cderv merged commit 5296880 into main Apr 16, 2026
4 checks passed
@cderv cderv deleted the fix/wasm-cfg-proxy-and-cleanup branch April 16, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants